<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        #app {
            background-color: rgb(10, 96, 153);
        }
        
        .second {
            background-color: rebeccapurple;
        }
        
        .third {
            background-color: rgb(145, 145, 238);
        }
    </style>
</head>

<body>
    <div id="app" class="root">
        <div>{{root}}</div>
        <second-com></second-com>
        <second-com></second-com>
    </div>
    <script type="text/javascript" src="../js/vue.js"></script>
    <script type="text/javascript">
        Vue.config.devtoools = true;
        Vue.component('second-com', {
            data: function() {
                return {
                    second: '二级组件'
                }
            },
            template: `<div class='second'>
                <div>{{second}}</div>
                <third-com></third-com>
                <third-com></third-com>
                <third-com></third-com>
            </div>`
        });
        Vue.component('third-com', {
            data: function() {
                return {
                    third: '三级组件'
                }
            },
            template: '<div class="third"><div>{{third}}</div></div>'
        });
        var m = new Vue({
            el: '#app',
            data: {
                root: '顶层组件'
            }
        })
    </script>
</body>

</html>